package com.ruan.controller;

import com.ruan.entity.ResponseResult;
import com.ruan.entity.User;
import com.ruan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @ClassName:UserController
 * @Author:阮昇
 * @Description:
 * @Datetime: 2023/7/19 14:51
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/register")
    public ResponseResult register(User user, String verifyCode, HttpSession session){
        if(!verifyCode.equalsIgnoreCase((String) session.getAttribute("verifyCode"))){
            return new ResponseResult(100,"验证码错误");
        }
        return userService.register(user);
    }
}
